#ifndef __HWLAYER_H__
#define __HWLAYER_H__
#include "sfsis.h"
typedef enum
{
    HWL_PIN_LT8920_RST,
    HWL_PIN_LT8920_PKT,
    HWL_PIN_LED1,
} HWL_GpioUsed;

typedef enum
{
    HWL_LOW,
    HWL_HIGH,
    HWL_INPUT,
    HWL_OUTPUT,
}HWL_GpioState;
/*GPIO接口*/
void hwl_gpio_set(HWL_GpioUsed hwl_gpio, HWL_GpioState value);//sf true high sf false low
HWL_GpioState hwl_gpio_get(HWL_GpioUsed hwl_gpio);


void hwl_adc_init();
void hwl_adc_start(void);
SF_Boolen hwl_adc_isConvertFinished(void);
su16 hwl_adc_getValue(void);

/*spi初始化，服务于lt8920*/
void hwl_spi_init(void);
void hwl_spi_SS_set(void);
void hwl_spi_SS_reset(void);
su8 hwl_spi_TRByte(su16 txbyte);
SF_Boolen hwl_spi_TxMultByte(su8 *txBuf, su16 count);
SF_Boolen hwl_spi_RxMultByte(su8 *rxBuf, su16 count);
/*iic接口*/
//默认硬件的device 地址，在sf中，没有必要特别高的读取效率
#define HWL_DEVICE_ADDRESS 0
void hwl_iic_init(void);
void hwl_iic_reset(void);
void hwl_iic_write(su8 address, su8 *buf, su16 buflen);
void hwl_iic_read(su8 address, su8 *buf, su16 readLen);
su8 hwl_iic_readReg(su8 address);
void hwl_iic_writeReg(su8 address, su8 value);
/*spi接口,服务于strip*/
void hwl_dma_spi_init(void);
//获取ram地址后，可以修改ram地址内的内容，修改完成后，调用update刷新到spi中
void hwl_dma_spi_transfer(void *buffer,su16 bufLen);
SF_Boolen hwl_dma_spi_isTransferBusy(void);

/*延时函数*/
void hwl_delay_us(su16 us);
void hwl_delay_ms(su16 ms);


void hwl_init(void);
#endif
